Program episode_50_days
      character*6 ticker(4000)
      character*8 cusp(4000)
      integer(kind=8):: nshrs(4000),ivol(4000),numshrs(4000)
      dimension nep(4000),ntype(4000),jast(4000),jdate(4000),itickt(4000),age(4000),favg(4000),fmax(4000),fmin(4000),fstd(4000)
      dimension iprm(4000),prc(4000),retr(4000),ishrout(4000),vwrt(4000),util(4000)
!      open(unit=10,file='e:\FIS_duration\episode_date_type.txt')
!      open(unit=99,file='e:\FIS_duration\episode_date_type_50_day.txt')
      open(unit=10,file='e:\FIS_duration\episode_date_type_rep.txt')
      open(unit=99,file='e:\FIS_duration\episode_date_type_50_day_rep.txt')
      iend=0
      i=0
1     i=i+1
      read(10,1000,end=900)nep(i),ntype(i),jast(i),jdate(i),cusp(i),ticker(i),itickt(i),numshrs(i),age(i),favg(i),fmax(i),fmin(i),fstd(i),iprm(i),prc(i),ivol(i),retr(i),ishrout(i),vwrt(i),util(i),nshrs(i)      
1000  format(1x,i4,1x,i1,2(1x,i8),1x,a8,2x,a6,4x,i9,1x,i14,5(1x,f11.4),1x,i5,1x,f9.2,1x,i10,1x,f10.6,1x,i9,1x,f9.6,1x,f6.2,1x,i13)  
      if(nep(i).eq.nep(1)) go to 1
5     icnt=i-1
      if(i.lt.50) go to 100
      do 20 k=1,icnt
20    write(99,1000)nep(k),ntype(k),jast(k),jdate(k),cusp(k),ticker(k),itickt(k),numshrs(k),age(k),favg(k),fmax(k),fmin(k),fstd(k),iprm(k),prc(k),ivol(k),retr(k),ishrout(k),vwrt(k),util(k),nshrs(k)      
100   nep(1)=nep(i)
      ntype(1)=ntype(i)
      jast(1)=jast(i)
      jdate(1)=jdate(i)
      cusp(1)=cusp(i)
      ticker(1)=ticker(i)
      itickt(1)=itickt(i)
      numshrs(1)=numshrs(i)
      age(1)=age(i)
      favg(1)=favg(i)
      fmax(1)=fmax(i)
      fmin(1)=fmin(i)
      fstd(1)=fstd(i)
      iprm(1)=iprm(i)
      prc(1)=prc(i)
      ivol(1)=ivol(i)
      retr(1)=retr(i)
      ishrout(1)=ishrout(i)
      vwrt(1)=vwrt(i)
      util(1)=util(i)
      nshrs(1)=nshrs(i) 
      i=1
      go to 1
900   continue
      iend=iend+1
      if(iend.eq.1) go to 5
      stop
end program episode_50_days